﻿using System;
using System.Net;
using System.Windows;
#if (WINRT)
using Windows.UI.Xaml;
using Windows.UI.Xaml.Markup;
using System.Windows.Input;
using nRoute.Components.Bindings;
using nRoute.Behaviors.Interactivity;
using System.ComponentModel;
using System.Windows.Interactivity;
using Windows.UI.Xaml.Data;
#else
using System.Windows.Markup;
using System.Windows.Input;
#endif

namespace nRoute.Components
{
    public abstract class VisualCommandBase
#if (WINRT)
        : AttachableDependencyObject
#else
        : DependencyObject
#endif
        , IVisualCommand
    {
        public static readonly DependencyProperty LabelProperty = DependencyProperty.Register("Label", typeof(string),
            typeof(VisualCommandBase), new PropertyMetadata(Utilities.Compatability.DP_UNSET_VALUE));

        public static readonly DependencyProperty IconPathProperty = DependencyProperty.Register("IconPath", typeof(string),
            typeof(VisualCommandBase), new PropertyMetadata(Utilities.Compatability.DP_UNSET_VALUE));

        public static readonly DependencyProperty IsVisibleProperty = DependencyProperty.Register("IsVisible", typeof(bool),
            typeof(VisualCommandBase), new PropertyMetadata(true));

        public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register("IsEnabled", typeof(bool),
            typeof(VisualCommandBase), new PropertyMetadata(true));

#region IVisualCommand Related

        public string Label
        {
            get { return Convert.ToString(GetValue(LabelProperty)); }
            set { SetValue(LabelProperty, value); }
        }

        public string IconPath
        {
            get { return Convert.ToString(GetValue(IconPathProperty)); }
            set { SetValue(IconPathProperty, value); }
        }

        public bool IsEnabled
        {
            get { return Convert.ToBoolean(GetValue(IsEnabledProperty)); }
            set { SetValue(IsEnabledProperty, value); }
        }

        public bool IsVisible
        {
            get { return Convert.ToBoolean(GetValue(IsVisibleProperty)); }
            set { SetValue(IsVisibleProperty, value); }
        }

        public abstract void Execute();

#endregion

#region Properties

#if (WINRT)

        [Category("Common Properties")]
        [CustomPropertyValueEditor(CustomPropertyValueEditor.PropertyBinding)]
        public Binding LabelBinding
        {
            get { return GetBinding(LabelProperty); }
            set { SetBinding<string>(LabelProperty, value); }
        }

        [Category("Common Properties")]
        [CustomPropertyValueEditor(CustomPropertyValueEditor.PropertyBinding)]
        public Binding IconPathBinding
        {
            get { return GetBinding(IconPathProperty); }
            set { SetBinding<string>(IconPathProperty, value); }
        }

        [Category("Common Properties")]
        [CustomPropertyValueEditor(CustomPropertyValueEditor.PropertyBinding)]
        public Binding IsVisibleBinding
        {
            get { return GetBinding(IsVisibleProperty); }
            set { SetBinding<bool>(IsVisibleProperty, value); }
        }

        [Category("Common Properties")]
        [CustomPropertyValueEditor(CustomPropertyValueEditor.PropertyBinding)]
        public Binding IsEnabledBinding
        {
            get { return GetBinding(IsEnabledProperty); }
            set { SetBinding<bool>(IsEnabledProperty, value); }
        }

#endif

#endregion

    }
}
